// @ts-ignore
/* eslint-disable */
import request from '@/request'

/** addCommunityPost POST /api/community/post/add */
export async function addCommunityPostUsingPost(
  body: API.CommunityPostAddRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseLong_>('/api/community/post/add', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** deleteCommunityPost POST /api/community/post/delete */
export async function deleteCommunityPostUsingPost(
  body: API.DeleteRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseBoolean_>('/api/community/post/delete', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** favoriteCommunityPost POST /api/community/post/favorite */
export async function favoriteCommunityPostUsingPost(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.favoriteCommunityPostUsingPOSTParams,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseBoolean_>('/api/community/post/favorite', {
    method: 'POST',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** getCommunityPostById GET /api/community/post/get */
export async function getCommunityPostByIdUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.getCommunityPostByIdUsingGETParams,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseCommunityPost_>('/api/community/post/get', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** getCommunityPostVOById GET /api/community/post/get/vo */
export async function getCommunityPostVoByIdUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.getCommunityPostVOByIdUsingGETParams,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseCommunityPostVO_>('/api/community/post/get/vo', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** listCommunityPostByPage POST /api/community/post/list/page */
export async function listCommunityPostByPageUsingPost(
  body: API.CommunityPostQueryRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponsePageCommunityPost_>('/api/community/post/list/page', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** listCommunityPostVOByPage POST /api/community/post/list/page/vo */
export async function listCommunityPostVoByPageUsingPost(
  body: API.CommunityPostQueryRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponsePageCommunityPostVO_>('/api/community/post/list/page/vo', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** unfavoriteCommunityPost POST /api/community/post/unfavorite */
export async function unfavoriteCommunityPostUsingPost(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.unfavoriteCommunityPostUsingPOSTParams,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseBoolean_>('/api/community/post/unfavorite', {
    method: 'POST',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** updateCommunityPost POST /api/community/post/update */
export async function updateCommunityPostUsingPost(
  body: API.CommunityPostEditRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseBoolean_>('/api/community/post/update', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** uploadPostPicture POST /api/community/post/uploadPicture */
export async function uploadPostPictureUsingPost(
  body: {},
  file?: File,
  options?: { [key: string]: any }
) {
  const formData = new FormData()

  if (file) {
    formData.append('file', file)
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele]

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''))
        } else {
          formData.append(ele, JSON.stringify(item))
        }
      } else {
        formData.append(ele, item)
      }
    }
  })

  return request<API.BaseResponseString_>('/api/community/post/uploadPicture', {
    method: 'POST',
    data: formData,
    requestType: 'form',
    ...(options || {}),
  })
}
